import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

import junit.framework.TestCase;


public class LiczbaTest extends TestCase {

	protected void setUp() throws Exception {
		super.setUp();
	}

	public void testDomyslnegoKonstruktora() throws Exception {
		Liczba l = new Liczba();
		for (int i = 2; i <= 17; ++i) {
			assertNotNull(l.zapis(i));
			assertTrue(l.zapis(i)=="0");
			assertFalse(l.zapis(i)!="0");
			assertSame(l.zapis(i),"0");
		}
	}

	public void testZaMalaPodstawa() throws Exception {
		try {
			new Liczba("1", 1);
			fail("LiczbaException not thrown");
		}
		catch (LiczbaException e) {}
	}

	public void testZaDuzaPodstawa() throws Exception {
		try {
			new Liczba("1", 18);
			fail("LiczbaException not thrown");
		}
		catch (LiczbaException e) {}
	}

	public void testPodstawaWZapisieZaMala() throws Exception {
		try {
			new Liczba("10", 10).zapis(1);
			fail("LiczbaException not thrown");
		}
		catch (LiczbaException e) {}
	}

	
	public void testPodstawaWZapisieZaDuza() throws Exception {
		try {
			new Liczba("10", 18).zapis(1);
			fail("LiczbaException not thrown");
		}
		catch (LiczbaException e) {}
	}
	
	public void testZapis() throws Exception {
		String[] inputs = {"16", "25", "99"};
		String[][] outputs = {
			{"10000", "121", "100", "31", "24", "22", "20", "17", "16", "15", "14", "13", "12", "11", "10", "G"},
			{"11001", "221", "121", "100", "41", "34", "31", "27", "25", "23", "21", "1C", "1B", "1A", "19", "18"},
			{"1100011", "10200", "1203", "344", "243", "201", "143", "120", "99", "90", "83", "78", "71", "69", "63", "5E"}, 
		};
		Liczba l = null;
		for (int i = 0; i < inputs.length; ++i) {
			l = new Liczba(inputs[i], 10);
			for (int j = 0; j < 16; ++j) {
				assertEquals(l.zapis(j + 2), outputs[i][j]);
			}
		}
	}
	
	protected void tearDown() throws Exception {
		super.tearDown();
	}

}
